<?php
namespace app\model;


class Member {
    
	static function getById($id) {
	    if (empty($id)) {
			return false;
		}
		$sql = "SELECT * FROM " . tablename(t_member) . " where id = :id";
		$row = db_find($sql, array(":id"=>$id));
		return $row;
	}

    static function getMcMemberByUId($uid) {
        if (empty($uid)) {
            return false;
        }
        $sql = "SELECT * FROM " . tablename("mc_members") . " where uid = :uid";
        $row = db_find($sql, array(":uid"=>$uid));
        return $row;
    }

    static function getByOpenId($openid,$uniacid) {
        if (empty($openid)) {
            return false;
        }
        $sql = "SELECT * FROM " . tablename(t_member) . " where openid = :openid and uniacid =:uniacid";
        $row = db_find($sql, array(":openid"=>$openid,":uniacid"=>$uniacid));
        return $row;
    }

    static function getCommByOpenId($id,$openid) {
        if (empty($id)) {
            return false;
        }
        $sql = "SELECT * FROM " . tablename(t_member) . " 
                        where  openid = :openid and paystate = 1 and ordertype = 'comm' order by id desc";
        $row = db_select($sql, array(":openid"=>$openid));
        return $row;
    }

    static function getByOrderId($id,$openid) {
        if (empty($id)) {
            return false;
        }
        $sql = "SELECT * FROM " . tablename(t_member) . " 
                        where orderid = :id and openid = :openid and paystate = 1 and ordertype = 'order' order by id desc";
        $row = db_find($sql, array(":id"=>$id,":openid"=>$openid));
        return $row;
    }
    static function getByMixId($openid,$orderid,$uniacid){
        if (empty($openid) || empty($orderid) || empty($uniacid)) {
            return false;
        }
        $sql = "SELECT * FROM " . tablename(t_member) . " 
                        where openid = :openid and orderid =:orderid and uniacid =:uniacid order by id desc";
        $row = db_find($sql, array(":openid"=>$openid,":orderid"=>$orderid,":uniacid"=>$uniacid));
        return $row;

    }
}
?>